1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package net.sf.webphotos.netbeans.project;
18
19 import java.awt.Image;
20 import javax.swing.Action;
21 import org.netbeans.spi.project.ui.LogicalViewProvider;
22 import org.netbeans.spi.project.ui.support.CommonProjectActions;
23 import org.openide.filesystems.FileObject;
24 import org.openide.loaders.DataFolder;
25 import org.openide.loaders.DataObjectNotFoundException;
26 import org.openide.nodes.AbstractNode;
27 import org.openide.nodes.Children;
28 import org.openide.nodes.FilterNode;
29 import org.openide.nodes.Node;
30 import org.openide.util.Exceptions;
31 import org.openide.util.ImageUtilities;
32 import org.openide.util.Lookup;
33 import org.openide.util.lookup.Lookups;
34 import org.openide.util.lookup.ProxyLookup;
35
36
37
38
39
40 class WebPhotosProjectLogicalView implements LogicalViewProvider {
41
42 private final WebPhotosProject webPhotosProject;
43
44 public WebPhotosProjectLogicalView(WebPhotosProject webPhotosProject) {
45 this.webPhotosProject = webPhotosProject;
46 }
47
48 @Override
49 public Node createLogicalView() {
50 try {
51
52 FileObject configuration = webPhotosProject.getFolder(0, true);
53
54
55 DataFolder configurationDataObject = DataFolder.findFolder(configuration);
56
57
58
59 Node realConfigurationFolderNode = configurationDataObject.getNodeDelegate();
60
61
62 return new ConfigurationNode(realConfigurationFolderNode, webPhotosProject);
63
64 } catch (DataObjectNotFoundException donfe) {
65 Exceptions.printStackTrace(donfe);
66
67
68 return new AbstractNode(Children.LEAF);
69 }
70 }
71
72
73
74
75 private static final class ConfigurationNode extends FilterNode {
76
77 final WebPhotosProject project;
78
79 public ConfigurationNode(Node node, WebPhotosProject project) throws DataObjectNotFoundException {
80 super(node, new FilterNode.Children(node),
81
82
83
84 new ProxyLookup(new Lookup[]{Lookups.singleton(project),
85 node.getLookup()
86 }));
87 this.project = project;
88 }
89
90 @Override
91 public Action[] getActions(boolean arg0) {
92 Action[] nodeActions = new Action[7];
93 nodeActions[0] = CommonProjectActions.newFileAction();
94 nodeActions[1] = CommonProjectActions.copyProjectAction();
95 nodeActions[2] = CommonProjectActions.deleteProjectAction();
96 nodeActions[5] = CommonProjectActions.setAsMainProjectAction();
97 nodeActions[6] = CommonProjectActions.closeProjectAction();
98 return nodeActions;
99 }
100
101 @Override
102 public Image getIcon(int type) {
103 return ImageUtilities.loadImage(Constants.PROJECT_ICON);
104 }
105
106 @Override
107 public Image getOpenedIcon(int type) {
108 return getIcon(type);
109 }
110
111 @Override
112 public String getDisplayName() {
113 return project.getProjectDirectory().getName();
114 }
115
116 }
117
118 @Override
119 public Node findPath(Node root, Object target) {
120
121 return null;
122 }
123
124 }